package com.sky.mapper;

import com.sky.dto.DishPageQueryDTO;
import com.sky.dto.SetmealDTO;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.entity.Setmeal;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;
import java.util.Set;

@Mapper
@Component
public interface SetmealMapper {

//    分页
    List<SetmealVO> list(SetmealPageQueryDTO dishDTO);

//    修改套餐
    @Update("update setmeal set name = #{name}, category_Id =#{categoryId},price = #{price}, image = #{image}, description= #{description} where id= #{id} ")
    void updateById(Setmeal setmeal);


//    套餐起售、停售
    @Update("update setmeal set status = #{status} where id =#{id}")
    Integer updateStatus(Long id,Integer status);

//    批量删除套餐
    @Delete(" delete from setmeal where id = #{id}")
    void removeById(Long  id);

//    新增套餐
    @Options(useGeneratedKeys = true,keyColumn = "id",keyProperty = "id")
    @Insert("Insert into setmeal (name, category_Id, price, image, description, status ) " +
            "values (#{name}, #{categoryId}, #{price}, #{image}, #{description}, #{status})")
    void save(SetmealDTO S);

//    根据id查询套餐
    @Select("select * from setmeal where id = #{id}")
    Setmeal selectById(Long id);

    List<Setmeal> selectByIdList();

    @Select("select * from setmeal where category_Id =#{id}")
    List<Setmeal> selectByCateId(Long id);

//    查询套餐售卖数量
    Integer countByMap(Map map);

}
